<?php 
class MyFrame{
	public static function Run(){
		//设置常量
		self::_set_const();
		//创建应用目录目录
		self::_create_dir();
		//加载核心类
		self::_import();
		//应用类执行
		Application::Run();
	}	

	private static function _set_const(){
		
		//适用于linux
		$path = str_replace("\\", "/", __FILE__);
		//定义框架地址
		define("MYFRAME_PATH", dirname($path));
		//
		define("CONFIG_PATH", MYFRAME_PATH."/Config");
		//
		define("LIB_PATH",MYFRAME_PATH."/Lib");
		define("CORE_PATH",LIB_PATH."/Core");
		 
		define("FUNCTION_PATH",LIB_PATH."/Function");
		
		//往上 定义 网站更目录
		define("ROOT_PATH", dirname(MYFRAME_PATH));
		
		//定义应用目录
		define("APP_PATH",ROOT_PATH . "/".APP_NAME);
		define("APP_CONFIG_PATH", APP_PATH."/Config");
		define("APP_CONTROLLER_PATH",APP_PATH."/Controller");
		define("APP_TPL_PATH",APP_PATH."/Tpl");
		define("APP_PUBLIC_PATH",APP_TPL_PATH."/Public");
		 
	}
	
	private static function _create_dir(){
		$dir_arr = [APP_PATH,APP_CONFIG_PATH,APP_CONTROLLER_PATH,APP_TPL_PATH,APP_PUBLIC_PATH];
		foreach ($dir_arr as $v){
			is_dir($v)||mkdir($v,0777,true);
		}
	}
	
	private static function _import(){
		$files = [
				CORE_PATH."/Application.class.php",
				CORE_PATH."/Controller.class.php",
				FUNCTION_PATH."/function.php"
		]; 
		
		foreach ($files as $f){
			require_once $f;
		}
	}
}

MyFrame::Run();
?>